﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace WpfApplication_Test
{
	public class InverseBooleanConverter : MarkupExtension, IValueConverter
	{
		#region IValueConverter Members

		public object Convert(object value, Type targetType, object parameter,
			System.Globalization.CultureInfo culture)
		{
			bool boolVal = value == null ? false : (bool)value;
			return !boolVal;
		}

		public object ConvertBack(object value, Type targetType, object parameter,
			System.Globalization.CultureInfo culture)
		{
			if (targetType != typeof(bool) && targetType != typeof(Visibility) && targetType != typeof(bool?))
			{
				throw new NotSupportedException();
			}
			return !(bool)value;
		}

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return this;
		}
		public InverseBooleanConverter() : base()
		{
		}
		#endregion
	}
}
